var vm = new Vue({
	el: '#app',
	data: {
		uid: '',
		dayList: ''
	},
	mounted: function() {
		console.log("mounted end");
		this.init();
	},
	methods: {
		init: function() {
			var self = this;
			self.uid = $api.getStorage('uid');
			apiready = function() {
				var fid = api.pageParam;
				console.log(fid.name);
				if(fid.name) {
					api.closeWin({
						name: fid.name
					});
				}
			}
			self.getDay();
		},
		getDay: function() {
			var self = this;

			var data = {
				uid: self.uid
			};
			$.post(base + config.study_calendar, data, function(msg) {
				console.log(msg);
				if(msg.error == 0) {
					self.dayList = msg.data;
					self.$nextTick(function() {
						// DOM 现在更新了
						// `this` 绑定到当前实例
						$('#calendar').calendar({
							ifSwitch: true, // 是否切换月份
							hoverDate: false, // hover是否显示当天信息
							backToday: false // 是否返回当天
						});
						var w = $(window).width();
						console.log(w);
						if(w >= 768) {
							$(".calendar").css("width", "490px");
							$(".calendar-week .item").css({
								"width": "70px"
							}, {
								"height": "70px"
							}, {
								"line-height": "70px"
							});
							$(".calendar-date .item").css({
								"width": "70px"
							}, {
								"height": "70px"
							}, {
								"line-height": "70px"
							});
						} else if(w <= 360) {
							$(".calendar").css("width", "300px");
							$(".calendar-week .item").css({
								"width": "42px"
							}, {
								"height": "42px"
							}, {
								"line-height": "42px"
							});
							$(".calendar-date .item").css({
								"width": "42px"
							}, {
								"height": "42px"
							}, {
								"line-height": "42px"
							});
						}
					});
				} else {
					console.log(msg.error_msg);
					api.toast({
						msg: msg.error_msg,
						duration: 2000,
						location: 'middle'
					});
				}
			}, 'json');
		},
		//关闭本页面
		close: function() {
			api.closeWin();
		}
	}
})